﻿using System;
namespace PageAdmin.Utils.ORM
{
    [AttributeUsage(AttributeTargets.Property, AllowMultiple = false, Inherited = true)]
    /// <summary>
    /// 搜索字段描述类
    /// </summary>
    public class SearchAttribute : Attribute
    {
        /// <summary>
        /// 
        /// </summary>
        /// <param name="searchTypeEnum">搜索类型</param>
        /// <param name="ignoreEmpty">是否忽视空值，true则为必须构造查询条件</param>
        public SearchAttribute(SearchTypeEnum searchTypeEnum,bool ignoreEmpty=true)
        {
            this.SearchType = searchTypeEnum;
            this.IgnoreEmpty = ignoreEmpty;
        }
        /// <summary>
        /// 搜索类型
        /// </summary>
        public SearchTypeEnum SearchType { get; set; }

        /// <summary>
        /// 是否忽视空值，没有构造时候则不构造查询条件。
        /// </summary>
        public bool IgnoreEmpty { get; set; } = true;

    }

    /// <summary>
    /// 搜索类型
    /// </summary>
    public enum SearchTypeEnum
    {
        /// <summary>
        /// 没有设置参数方式
        /// </summary>
        NoQuery =0,

        /// <summary>
        /// 精确查询
        /// </summary>
        PreciseQuery = 1,

        /// <summary>
        /// 模糊查询
        /// </summary>
        Fuzzyquery = 2,

        /// <summary>
        /// 范围查询，如日期段,between and 
        /// </summary>
        RangeQuery = 3,

        /// <summary>
        /// in查询如，in in(1,2,3)
        /// </summary>
        InQuery = 4,

        /// <summary>
        /// 大于
        /// </summary>
        GreaterThanQuery = 5,

        /// <summary>
        /// 大于等于
        /// </summary>
        GreaterThanEqualQuery = 6,

        /// <summary>
        /// 小于
        /// </summary>
        LessThanQuery = 7,

        /// <summary>
        /// 小于等于
        /// </summary>
        LessThanEqualQuery =8,
    }

}
